<html>
<head><meta charset="utf-8"><title>FalseEdges in MIR CFG · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html">FalseEdges in MIR CFG</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226237579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226237579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226237579">(Feb 13 2021 at 10:06)</a>:</h4>
<p>Where can I learn more about "false edges" in MIR CFG? I searched for it in rustc guide, I also checked the rustdocs:</p>
<div class="codehilite"><pre><span></span><code>    /// A block where control flow only ever takes one real path, but borrowck
    /// needs to be more conservative.
    FalseEdge {
        /// The target normal control flow will take.
        real_target: BasicBlock,
        /// A block control flow could conceptually jump to, but won&#39;t in
        /// practice.
        imaginary_target: BasicBlock,
    },
</code></pre></div>
<p>The variant documentation doesn't say why borrowck needs to be more conservative and needs <code>imaginary_target</code>. The field documentation is also confusing. It says "control flow could conceptually jump to", but when I look at some actual MIR like</p>
<div class="codehilite"><pre><span></span><code>fn test(_1: [u32; 2]) -&gt; () {
    debug dwords =&gt; _1;                  // in scope 0 at test.rs:3:13: 3:19
    let mut _0: ();                      // return place in scope 0 at test.rs:3:31: 3:31
    let _2: u32;                         // in scope 0 at test.rs:5:17: 5:20
    scope 1 {
        debug _ip =&gt; _2;                 // in scope 1 at test.rs:5:17: 5:20
    }

    bb0: {
        FakeRead(ForMatchedPlace, _1);   // scope 0 at test.rs:4:11: 4:17
        switchInt(_1[0 of 2]) -&gt; [0_u32: bb1, 1_u32: bb2, otherwise: bb3]; // scope 0 at test.rs:5:10: 5:11
    }

    bb1: {
        falseEdge -&gt; [real: bb5, imaginary: bb2]; // scope 0 at test.rs:5:10: 5:11
    }

    bb2: {
        falseEdge -&gt; [real: bb6, imaginary: bb3]; // scope 0 at test.rs:5:14: 5:15
    }

    bb3: {
        _0 = ();                         // scope 0 at test.rs:6:14: 6:16
        goto -&gt; bb7;                     // scope 0 at test.rs:4:5: 7:6
    }

    bb4: {
        _0 = ();                         // scope 1 at test.rs:5:25: 5:27
        StorageDead(_2);                 // scope 0 at test.rs:5:26: 5:27
        goto -&gt; bb7;                     // scope 0 at test.rs:4:5: 7:6
    }

    bb5: {
        StorageLive(_2);                 // scope 0 at test.rs:5:17: 5:20
        _2 = _1[1 of 2];                 // scope 0 at test.rs:5:17: 5:20
        goto -&gt; bb4;                     // scope 0 at test.rs:4:5: 7:6
    }

    bb6: {
        StorageLive(_2);                 // scope 0 at test.rs:5:17: 5:20
        _2 = _1[1 of 2];                 // scope 0 at test.rs:5:17: 5:20
        goto -&gt; bb4;                     // scope 0 at test.rs:4:5: 7:6
    }

    bb7: {
        return;                          // scope 0 at test.rs:8:2: 8:2
    }
}
</code></pre></div>
<p>Here <code>bb2</code> can't "conceptually" jump to <code>bb3</code>, right? That path would be <code>bb2-&gt;bb3-&gt;bb7</code> which is different than <code>bb2-&gt;bb6-&gt;bb4-&gt;bb7</code>, because the first path doesn't update <code>_2</code> but the second path does.</p>
<p>Do we have any documentation on this stuff?</p>



<a name="226237738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226237738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226237738">(Feb 13 2021 at 10:11)</a>:</h4>
<p>If you would for example have</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// some code</span>
<span class="w">    </span><span class="k">loop</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="c1">// some other code</span>
</code></pre></div>
<p>"some other code" wouldn't be borrow checked if it weren't for the false edge from the loop to "some other code".</p>



<a name="226237928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226237928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226237928">(Feb 13 2021 at 10:17)</a>:</h4>
<p>This might be a bad example, since the code that follows isn't borrow checked.</p>



<a name="226237985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226237985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226237985">(Feb 13 2021 at 10:18)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">f</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="k">loop</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">a</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="226238137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226238137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226238137">(Feb 13 2021 at 10:23)</a>:</h4>
<p>Yeah it seems like 'some other code' is not really borrow checked. Would be good to see an example where these "imaginary" edges are really necessary.</p>



<a name="226238188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226238188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226238188">(Feb 13 2021 at 10:25)</a>:</h4>
<p>If you are interested in the answer I would look where in <code>rustc_mir_build</code> the <code>TerminatorKind::FalseEdge</code> is constructed.</p>



<a name="226240679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226240679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226240679">(Feb 13 2021 at 11:28)</a>:</h4>
<p><code>ui/borrowck/borrowck-drop-from-guard.rs</code> would be one example</p>



<a name="226254799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226254799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gwaihir Thorondorsen <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226254799">(Feb 13 2021 at 16:53)</a>:</h4>
<p><span class="user-mention" data-user-id="119169">@osa1</span> Does <a href="https://rust-lang.github.io/rfcs/2094-nll.html#layer-2-avoiding-infinite-loops">this section</a> of the NLL RFC help in any way?</p>



<a name="226254848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226254848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226254848">(Feb 13 2021 at 16:54)</a>:</h4>
<p>That's for false unwinds.</p>



<a name="226254922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226254922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226254922">(Feb 13 2021 at 16:56)</a>:</h4>
<p>False edges are used to make match statements borrow check as if they were if-else chains</p>



<a name="226255146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255146">(Feb 13 2021 at 17:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> could you say more please? Why would match expressions be borrow checked differently than if expressions?</p>



<a name="226255174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255174">(Feb 13 2021 at 17:01)</a>:</h4>
<p>let me find an example...</p>



<a name="226255281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255281">(Feb 13 2021 at 17:03)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/58646">#58646</a></p>



<a name="226255294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255294">(Feb 13 2021 at 17:03)</a>:</h4>
<p>Relevant example is</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">all_previous_tests_may_be_done</span><span class="p">(</span><span class="n">y</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">(</span><span class="kt">bool</span><span class="p">,</span><span class="w"> </span><span class="kt">bool</span><span class="p">))</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">y</span><span class="p">.</span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="c1">// We don't actually test y.1 to select the second arm, but we don't want</span>
<span class="w">    </span><span class="c1">// borrowck results to be based on the order we match patterns.</span>
<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="p">(</span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="c1">//~ ERROR cannot use `y.1` because it was mutably borrowed</span>
<span class="w">        </span><span class="p">(</span><span class="kc">true</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">r</span><span class="p">;</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// (use of "above" borrow)</span>
<span class="w">        </span><span class="p">(</span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="226255656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gwaihir Thorondorsen <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255656">(Feb 13 2021 at 17:10)</a>:</h4>
<p>History: <a href="https://github.com/rust-lang/rust/issues/45043">#45043</a> &amp; <a href="https://github.com/rust-lang/rust/issues/45184">#45184</a> introduced false edges for <code>match</code>, then they were <a href="https://github.com/rust-lang/rust/issues/46036#issuecomment-358400433">considered</a> when implementing false <em>unwind</em> edges for <code>loop</code> but <a href="https://github.com/rust-lang/rust/issues/47802">eventually</a> got implemented separately. Is that more accurate? The terminology is definitely confusing.</p>



<a name="226255782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255782">(Feb 13 2021 at 17:12)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="116118">@Matthew Jasper</span>  for the example. In the MIR for that example, if I remove all false edges, it would still not borrow check, no? Because the place y.1 is borrowed mutably when used for switching. Relevant parts of the MIR:</p>
<div class="codehilite"><pre><span></span><code>fn all_previous_tests_may_be_done(_1: &amp;mut (bool, bool)) -&gt; () {
    debug y =&gt; _1;                       // in scope 0 at test.rs:1:39: 1:40
    let mut _0: ();                      // return place in scope 0 at test.rs:1:61: 1:61
    let _2: &amp;mut bool;                   // in scope 0 at test.rs:2:9: 2:10
    let _3: i32;                         // in scope 0 at test.rs:3:5: 10:6
    let _4: &amp;mut bool;                   // in scope 0 at test.rs:6:13: 6:14
    scope 1 {
        debug r =&gt; _2;                   // in scope 1 at test.rs:2:9: 2:10
    }

    bb0: {
        StorageLive(_2);                 // scope 0 at test.rs:2:9: 2:10
        _2 = &amp;mut ((*_1).1: bool);       // scope 0 at test.rs:2:13: 2:21
        FakeRead(ForLet, _2);            // scope 0 at test.rs:2:9: 2:10
        StorageLive(_3);                 // scope 1 at test.rs:3:5: 10:6
        FakeRead(ForMatchedPlace, _1);   // scope 1 at test.rs:3:11: 3:12
        switchInt(((*_1).0: bool)) -&gt; [false: bb1, otherwise: bb4]; // scope 1 at test.rs:4:10: 4:15
    }

    bb1: {
        switchInt(((*_1).1: bool)) -&gt; [false: bb3, otherwise: bb2]; // scope 1 at test.rs:4:17: 4:21
    }

    ...
</code></pre></div>
<p>Here, in <code>bb1</code>, <code>_2</code> is still live.</p>



<a name="226255818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226255818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226255818">(Feb 13 2021 at 17:13)</a>:</h4>
<p><span class="user-mention" data-user-id="369545">@Gwaihir Thorondorsen</span> thanks, I'll read the issues for background.</p>



<a name="226257612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226257612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226257612">(Feb 13 2021 at 17:46)</a>:</h4>
<p><code>_2</code> isn't live in bb1 if you don't consider false edges (<code>StorageDead</code> is not a use)</p>



<a name="226258248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258248">(Feb 13 2021 at 17:58)</a>:</h4>
<p>OK, I think <a href="https://github.com/rust-lang/rust/issues/45184">#45184</a> is the best documentation on this. Why I was curious about this is because I think these false edges prevent some optimizations. For example, they're considered as successors in <a href="https://github.com/rust-lang/rust/blob/7e0241c63755ea28045d512b742f50b307874419/compiler/rustc_middle/src/mir/terminator.rs#L331-L333">https://github.com/rust-lang/rust/blob/7e0241c63755ea28045d512b742f50b307874419/compiler/rustc_middle/src/mir/terminator.rs#L331-L333</a> , as a result <a href="https://github.com/rust-lang/rust/blob/7e0241c63755ea28045d512b742f50b307874419/compiler/rustc_mir/src/transform/simplify.rs#L119-L121">https://github.com/rust-lang/rust/blob/7e0241c63755ea28045d512b742f50b307874419/compiler/rustc_mir/src/transform/simplify.rs#L119-L121</a> can't optimize some trivial goto chains.</p>



<a name="226258297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258297">(Feb 13 2021 at 17:59)</a>:</h4>
<p>The false edges should have been removed after borrowck. As far as I know.</p>



<a name="226258316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258316">(Feb 13 2021 at 17:59)</a>:</h4>
<p>It's not really a trivial goto chain if there are false edges into it</p>



<a name="226258401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258401">(Feb 13 2021 at 18:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116118">Matthew Jasper</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/FalseEdges.20in.20MIR.20CFG/near/226257612">said</a>:</p>
<blockquote>
<p><code>_2</code> isn't live in bb1 if you don't consider false edges (<code>StorageDead</code> is not a use)</p>
</blockquote>
<p>Hmm, I thought it's live between <code>StorageLive(_2)</code> in <code>bb0</code> and <code>StorageDead(_2)</code> in <code>bb7</code>, and to visit <code>bb1</code> you have to go through <code>StorageLive(_2)</code> in <code>bb0</code>. So it's not dead yet in <code>bb1</code>.</p>



<a name="226258445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258445">(Feb 13 2021 at 18:01)</a>:</h4>
<p>It's  "storage live", but that's not the notion of liveness that the borrow checker uses to infer lifetimes.</p>



<a name="226258498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258498">(Feb 13 2021 at 18:02)</a>:</h4>
<p>Using storage liveness to determine lifetimes would be lexical lifetimes.</p>



<a name="226258507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258507">(Feb 13 2021 at 18:02)</a>:</h4>
<p>simplify-branches turns <code>FalseEdge</code> and <code>FalseUnwind</code> into <code>Goto</code>: <a href="https://github.com/rust-lang/rust/blob/89fdb30892dbe330730ad1a1c1fe45b9046c2973/compiler/rustc_mir/src/transform/simplify_branches.rs#L56-L61">https://github.com/rust-lang/rust/blob/89fdb30892dbe330730ad1a1c1fe45b9046c2973/compiler/rustc_mir/src/transform/simplify_branches.rs#L56-L61</a></p>



<a name="226258567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/FalseEdges%20in%20MIR%20CFG/near/226258567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/FalseEdges.20in.20MIR.20CFG.html#226258567">(Feb 13 2021 at 18:03)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> interesting, thanks. I'll see why that can't optimize the MIR I'm looking at.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>